package com.person.android.ui.fragments;

import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

import com.person.android.dao.TransformRecordData;
import com.person.android.domain.adapters.TransformAdapter;
import com.person.android.formatts.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by zhaokang on 2015/11/29.
 */
public class HomeFragment extends Fragment implements AdapterView.OnItemClickListener {

    private View mView;
    private Context mContext;

    private TransformAdapter mTransformAdapter;
    private List<TransformRecordData> mDataList;
    private ListView mTransformRecordListView;//转换记录列表


    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        mView = inflater.inflate(R.layout.fragment_home,container,false);
        mContext = mView.getContext();
        findViews();
        setOnItemListeners();
        return mView;
    }

    private void findViews() {
        mDataList = getDataList();
        mTransformAdapter = new TransformAdapter(mContext,mDataList);
        mTransformRecordListView = (ListView) mView.findViewById(R.id.transform_lv);

        mTransformRecordListView.setAdapter(mTransformAdapter);
    }

    private List<TransformRecordData> getDataList(){
        List<TransformRecordData> result = new ArrayList<>();
        for(int i = 0;i < 10;i++){
            result.add(new TransformRecordData());
        }
        return result;
    }

    private void setOnItemListeners(){
        mTransformRecordListView.setOnItemClickListener(this);
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {

    }
}
